package com.hxzy.service.impl;

import com.hxzy.entity.UmsAdminLoginLog;
import com.hxzy.mapper.UmsAdminLoginLogMapper;
import com.hxzy.service.UmsAdminLoginLogService;
import com.hxzy.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

public class UmsAdminLoginLogServiceImpl implements UmsAdminLoginLogService {
    @Override
    public UmsAdminLoginLog selectByPrimaryKey(Long id) {
        UmsAdminLoginLog umsAdminLoginLog=null;
        try (SqlSession session= MybatisUtil.getSqlSessionFactory().openSession()){
            UmsAdminLoginLogMapper mapper = session.getMapper(UmsAdminLoginLogMapper.class);
            umsAdminLoginLog=mapper.selectByPrimaryKey(id);
        }
        return umsAdminLoginLog;
    }

    @Override
    public boolean updateByPrimaryKey(UmsAdminLoginLog record) {
        int count = 0;
        try (SqlSession session = MybatisUtil.getSqlSessionFactory().openSession()) {
            UmsAdminLoginLogMapper mapper = session.getMapper(UmsAdminLoginLogMapper.class);
            count = mapper.updateByPrimaryKey(record);
        }
        return count > 0;
    }

    @Override
    public boolean insert(UmsAdminLoginLog record) {
        int count = 0;
        try (SqlSession session = MybatisUtil.getSqlSessionFactory().openSession()) {
            UmsAdminLoginLogMapper mapper = session.getMapper(UmsAdminLoginLogMapper.class);
            count = mapper.insert(record);
        }
        return count > 0;
    }
}
